import axios from 'axios'
import Vue from 'vue'
// 进度条
import NProgress from 'nprogress'
// import 'nprogress/nprogress.css'
// 配置baseURL
// axios.defaults.baseURL = 'https://120.79.70.168:8202/api/private/v1/'
axios.defaults.baseURL = 'https://lezaizhu.top:8202/api/private/v1/'
// 添加到vue原型

// 添加忽略证书 rejectUnauthorized: false
// const https = require('https')
// const instance = axios.create({
//   baseURL: 'https://120.79.70.168:8202/api/private/v1/',
//   timeout: 1000,
//   httpsAgent: new https.Agent({
//     rejectUnauthorized: false
//   })
// })

axios.interceptors.request.use(config => {
  NProgress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})

Vue.prototype.$http = axios
